﻿using System;
using System.Net;
using System.Xml.Linq;
using System.Linq;

namespace ArmoryBrowser.Entities
{
    public class CharacterPage
    {
        #region Fields
        private TabInfo _tabInfoField;
        private CharacterInfo _characterInfoField;
        private string _globalSearchField;
        private string _langField;
        private string _requestUrlField;
        #endregion
        #region Properties
        public TabInfo TabInfo
        {
            get
            {
                return this._tabInfoField;
            }
            set
            {
                this._tabInfoField = value;
            }
        }

        public CharacterInfo CharacterInfo
        {
            get
            {
                return this._characterInfoField;
            }
            set
            {
                this._characterInfoField = value;
            }
        }

        public string GlobalSearch
        {
            get
            {
                return this._globalSearchField;
            }
            set
            {
                this._globalSearchField = value;
            }
        }

        public string Lang
        {
            get
            {
                return this._langField;
            }
            set
            {
                this._langField = value;
            }
        }

        public string RequestUrl
        {
            get
            {
                return this._requestUrlField;
            }
            set
            {
                this._requestUrlField = value;
            }
        }
        #endregion
        #region Constructor
        public CharacterPage(XElement element)
        {
            GlobalSearch = element.GetAttributeValue("globalSearch");
            Lang = element.GetAttributeValue("lang");
            RequestUrl = element.GetAttributeValue("requestUrl");
            TabInfo = element.Elements("tabInfo").Select(e => new TabInfo(e)).FirstOrDefault();
            CharacterInfo = element.Elements("characterInfo").Select(e => new CharacterInfo(e)).FirstOrDefault();
        }
        #endregion
    }
}
